﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace UI
{
    public class UILuckCenterHeroTemplate : UILuckOneHeroTemplate
    {
        protected override void Center()
        {
            center = true;
        }

        public override void DictData()
        {
            heros = new List<UIHero>();

            foreach (var kvp in StaticData.playerData.InstPlayerData.BattleCamps)
            {
                var hero = kvp.Value.hero;
                if(hero!=null && hero.heroId == luck.luckData.heroId)
                {
                    heros.Add(hero);
                    break;
                }
            }
        }

        public override void InitMasked()
        {
            masked = new List<bool>();
            masked.Add(false);
            SetMasked(masked);
        }

        public override void OnClick()
        {
            foreach(var battle in StaticData.playerData.InstPlayerData.BattleCamps)
            {
                if(battle.Value!=null && battle.Value.hero != null && battle.Value.hero.heroId == luck.luckData.heroId)
                {
                    PageManager.Instance.OpenPage("UIHeroPage", "guid=" + battle.Value.hero.guid);
                    var page = PageManager.Instance.currentPage as UIHeroPage;
                    if(page!=null)
                    {
                        page.logic.SetHero(false, false, true);
                    }
                    break;
                }
            }
        }
    }
}